package com.ktjy.cvs.config;

import com.ktjy.cvs.pojo.SysRole;
import com.ktjy.cvs.pojo.SysUser;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

/**
 * @author Jane
 * @date 2024-12-20 10:53
 */

@Configuration
public class UserConfig {

    @Bean("user")
//    public SysUser zhangsan(SysRole role){
    public SysUser zhangsan(@Qualifier("role_manager")SysRole role){
        SysUser sysUser = new SysUser();
        sysUser.setAccount("T373_zhangsan");
        sysUser.setPassword("123456");

        sysUser.setSysRole(role);

        return sysUser;
    }

    //角色 有管理员,有店长
    @Bean("role_admin")
    @Primary
    public SysRole role_admin(){
        SysRole role =new SysRole();
        role.setId(1L);
        role.setRolename("管理员");
        role.setCode("ADMIN");
        return role;
    }

    @Bean("role_manager")
    public SysRole role_manager(){
        SysRole role =new SysRole();
        role.setId(2L);
        role.setRolename("店长");
        role.setCode("MANAGER");
        return role;
    }
}
